﻿using System;
using System.Data;
using ChapterX.BusinessFacade;
using ChapterX.Common;
using ChapterX.Data.BooksDSTableAdapters;

namespace ChapterX.Modules
{
    public partial class CourseBookListModule : ChapterX.Model.DataListModuleBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindCourseBookList();
            }
        }

        protected void BindCourseBookList()
        {
            int courseId;

            if (Int32.TryParse(Request.QueryString[QueryKeys.COURSE_ID], out courseId))
            {
                try
                {
                    CourseBookViewTableAdapter adpater = new CourseBookViewTableAdapter();
                    CourseBookList.DataSource = adpater.GetBookListByCourseId(courseId);
                    CourseBookList.DataBind();
                }
                catch (Exception ex)
                {
                    SetErrorMessage("数据绑定失败。");
                    Logger.Log(ex);
                }
            }
        }
    }
}